/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.shs.service.mydata;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.service.CrudService;
import com.thinkgem.jeesite.common.utils.IdGen;
import com.thinkgem.jeesite.modules.shs.entity.mydata.ShsMydata;
import com.thinkgem.jeesite.modules.shs.dao.mydata.ShsMydataDao;

/**
 * 我要数据Service
 * @author lj
 * @version 2018-06-07
 */
@Service
@Transactional(readOnly = true)
public class ShsMydataService extends CrudService<ShsMydataDao, ShsMydata> {

	public ShsMydata get(String id) {
		return super.get(id);
	}
	
	public List<ShsMydata> findList(ShsMydata shsMydata) {
		return super.findList(shsMydata);
	}
	
	public Page<ShsMydata> findPage(Page<ShsMydata> page, ShsMydata shsMydata) {
		return super.findPage(page, shsMydata);
	}
	
	@Transactional(readOnly = false)
	public void save(ShsMydata shsMydata) {
		super.save(shsMydata);
	}
	
	@Transactional(readOnly = false)
	public void delete(ShsMydata shsMydata) {
		super.delete(shsMydata);
	}
	
	@Transactional(readOnly = false)
	public Map<String,Object> submitMyData(ShsMydata shsMydata) {
		Map<String,Object> result = new HashMap<String, Object>();
		try {
			shsMydata.setId(IdGen.uuid());
			shsMydata.setCreateDate(new Date());
			dao.submitMyData(shsMydata);
			result.put("success", 1);
			result.put("msg", "保存成功");
			return result;
		} catch (Exception e) {
			e.printStackTrace();
			result.put("success", -1);
			result.put("msg", "保存失败");
			return result;
		}
	
	}
	@Transactional(readOnly = false)
	public Map<String,Object> countMyData() {
		Map<String,Object> result = new HashMap<String, Object>();
		try {
			result.put("data",dao.countMyData());
			result.put("percent", dao.percentMyData()==null?0:dao.percentMyData());
			result.put("success", 1);
			result.put("msg", "接口调用成功");
			return result;
		} catch (Exception e) {
			e.printStackTrace();
			result.put("success", -1);
			result.put("msg", "接口调用失败");
			return result;
		}
		
	}
	
}